
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Length.h>

using namespace std;

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(LengthWithSameUnit)
{
	TEST(Length with 8 miles equals length with 8 miles)
	{
		Length  length_A(8,MILE);
                Length  length_B(8,MILE);
                ASSERT_TRUE(length_A == length_B);
	}

        TEST(Length with 8 miles not equals length with 6 miles)
	{
		Length  length_A(8,MILE);
                Length  length_B(6,MILE);
		ASSERT_TRUE(length_A!=length_B);
	}


        TEST(Length with 8 yards equals length with 8 yards)
	{
		Length  length_A(8,YARD);
                Length  length_B(8,YARD);
		ASSERT_TRUE(length_A==length_B);
	}

        TEST(Length with 8 yards not equals length with 6 yards)
	{
		Length  length_A(8,YARD);
                Length  length_B(6,YARD);
		ASSERT_TRUE(length_A!=length_B);
	}

        TEST(Length with 8 feets equals length with 8 feets)
	{
		Length  length_A(8,FEET);
                Length  length_B(8,FEET);
		ASSERT_TRUE(length_A==length_B);
	} 

        TEST(Length with 8 feets not equals length with 6 feets)
	{
		Length  length_A(8,FEET);
                Length  length_B(6,FEET);
		ASSERT_TRUE(length_A!=length_B);
	}           

};


FIXTURE(LengthWithDifferentUnit)
{
	TEST(Length with 8 miles equals length with 14080 yards)
	{
		Length  length_A(8,MILE);
                Length  length_B(14080,YARD);
		ASSERT_TRUE(length_A==length_B);
	}

        TEST(Length with 8 miles not equals length with 14079 yards)
	{
		Length  length_A(8,MILE);
                Length  length_B(14079,YARD);
		ASSERT_TRUE(length_A!=length_B);
	}

        TEST(Length with 8 miles equals length with 42240 feets)
	{
		Length  length_A(8,MILE);
                Length  length_B(42240,FEET);
		ASSERT_TRUE(length_A==length_B);
	}

        TEST(Length with 8 miles not equals length with 42241 feets)
	{
		Length  length_A(8,MILE);
                Length  length_B(42241,FEET);
		ASSERT_TRUE(length_A!=length_B);
	}

        TEST(Length with 3520 yards equals length with 10560 mile)
	{
		Length  length_A(3520,YARD);
                Length  length_B(10560,FEET);
		ASSERT_TRUE(length_A==length_B);
	}

        TEST(Length with 3519 yards not equals length with 10560 miles)
	{
		Length  length_A(3519,YARD);
                Length  length_B(10560,FEET);
		ASSERT_TRUE(length_A!=length_B);
	}      

};


FIXTURE(LengthPlusWithSameUnit)
{
	TEST(Length with 8 miles + length with 2 miles ==Length with 10 miles )
	{
		Length  length_A(8,MILE);
                Length  length_B(2,MILE);
                Length  length_C(10,MILE);
		ASSERT_TRUE(length_C==length_A+length_B);
	}

        TEST(Length with 8 yards + length with 2 yards==Length with 10 yards)
	{
		Length  length_A(8,YARD);
                Length  length_B(2,YARD);
                Length  length_C(10,YARD);
		ASSERT_TRUE(length_C==length_A+length_B);
	}

        TEST(Length with 8 feet + length with 2 feet==Length with 10 feet)
	{
		Length  length_A(8,FEET);
                Length  length_B(2,FEET);
                Length  length_C(10,FEET);
		ASSERT_TRUE(length_C==length_A+length_B);
	}
};

FIXTURE(LengthPlusWithDifferentUnit)
{
    TEST(Length with 8 miles +length with 2 yards ==Length with 14082 yards )
	{
		Length  length_A(8,MILE);
                Length  length_B(2,YARD);
                Length  length_C(14082,YARD);
		ASSERT_TRUE(length_C==length_A+length_B);
	}

    TEST(Length with 8 miles + length with 2 feet==Length with 42242 FEET)
	{
		Length  length_A(8,MILE);
                Length  length_B(2,FEET);
                Length  length_C(42242,FEET);
		ASSERT_TRUE(length_C==length_A+length_B);
	}

        TEST(Length with 8 yards + length with 2 feet==Length with 26 feet)
	{
		Length  length_A(8,YARD);
                Length  length_B(2,FEET);
                Length  length_C(26,FEET);
		ASSERT_TRUE(length_C==length_A+length_B);
	}

};
        
string TESTOUTPUT(int amount, const LengthUnit* unit)
{
        std::ostringstream stream;
        Length length(amount, unit);
        length.output(stream, MILE);
        return stream.str();
}

string OUTPUT_BASEUNIT(int amount, const LengthUnit* unit)
{
        std::ostringstream stream;
        Length length(amount, unit);
        length.output(stream, BASE_LENGTH_UNIT);
        return stream.str();
}

FIXTURE(FormatOutput)
{
        TEST(Length with 8 miles, display as"8 MILE")
        {
                ASSERT_TRUE("8 MILE"==TESTOUTPUT(8, MILE));
        }

        TEST(Length with 8 yards, display as"8 YARD")
        {
                ASSERT_TRUE("8 YARD"==TESTOUTPUT(8, YARD));
        }

        TEST(Length with 2 feets, display as"2 FEET")
        {
                ASSERT_TRUE("2 FEET"==TESTOUTPUT(2, FEET));
        }

        TEST(Length with 5000 yards, display as"2 MILE 1480 YARD")
        {
                ASSERT_TRUE("2 MILE 1480 YARD"==TESTOUTPUT(5000, YARD));
        }

        TEST(Length with 8000 feets, display as"1 MILE 906 YARD 2 FEET")
        {
                ASSERT_TRUE("1 MILE 906 YARD 2 FEET"==TESTOUTPUT(8000, FEET));
        }

        TEST(Length with 10561 feets, display as"2 MILE 1 FEET")
        {
                ASSERT_TRUE("2 MILE 1 FEET"==TESTOUTPUT(10561, FEET));
        }

        TEST(Length with 5000 yards, display as"15000 FEET")
        {
                ASSERT_TRUE("15000 FEET"==OUTPUT_BASEUNIT(5000, YARD));
        }

        TEST(Length with 8000 feets, display as"8000 FEET")
        {
                ASSERT_TRUE("8000 FEET"==OUTPUT_BASEUNIT(8000, FEET));
        }

        TEST(Length with 3 miles, display as"15840 FEET")
        {
                ASSERT_TRUE("15840 FEET"==OUTPUT_BASEUNIT(3, MILE));
        }

};
